﻿//===============================================================================
// La Pomme d'Or Krystal Application
// Windows Presentation Foundation Composite Application 
//===============================================================================
// Copyright (c) Jérôme Piquot.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.Collections.Generic;
using System.Collections;

namespace PJ.Data
{
    /// <summary>
    /// Saves and retreive <see cref="IItemData"/> instance to/from cache
    /// </summary>
    public interface IItemCache : IEntityCache
    {
        /// <summary>
        /// Finds the <see cref="IItemData"/> instance in the cache.
        /// </summary>
        /// <param name="itemName"><see cref="IItemData"/> name</param>
        /// <returns>The <see cref="IItemData"/> instance in the cache having Id equal to <paramref name="itemName"/> if found or returns <see langword="null" /></returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="itemName"/> is <see langword="null" /> or empty.</exception>
        IItemData FindByName(string itemName);

        /// <summary>
        /// Finds the <see cref="IItemData"/> instance in the cache.
        /// </summary>
        /// <param name="itemAlias"><see cref="IItemData"/> aliasName</param>
        /// <returns>The <see cref="IItemData"/> instance in the cache having Id equal to <paramref name="itemAlias"/> if found or returns <see langword="null" /></returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="itemAlias"/> is <see langword="null" /> or empty.</exception>
        IItemData FindByAlias(string itemAlias);

        /// <summary>
        /// Gets the <see cref="IItemData"/> Search collection from the cache.
        /// </summary>
        /// <param name="searchText">Search criteria</param>
        /// <returns>The item global ids array if found else returns <see langword="null" /></returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="searchText"/> is <see langword="null" /> or empty.</exception>
        string[] Search(string searchText);


        /// <summary>
        /// Adds the <see cref="IItemData"/> collection to the cache.
        /// </summary>
        /// <param name="searchText">Search criteria</param>
        /// <param name="globalIds">The items global ids array to add</param>
        /// <returns><paramref name="globalIds"/> value<see langword="null" /></returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="searchText"/> is <see langword="null" /> or empty. Or if <paramref name="collection"/> is <see langword="null" /></exception>
        /// <exception cref="ArgumentException">If the passed <paramref name="collection"/> is empty or if it contains objects types that are not <see cref="IItemData"/>.</exception>
        string[] AddSearch(string searchText, string[] globalIds);
    }
    /// <summary>
    /// Saves and retreive <see cref="IItemData"/> instance to/from cache
    /// </summary>
    /// <typeparam name="T"><see cref="IItemData">Item</see> data concrete class type to cache.</typeparam>
    public interface IItemCache<T> : IEntityCache<T>, IItemCache
        where T : IItemData
    {
        /// <summary>
        /// Finds the <see cref="IItemData"/> instance in the cache.
        /// </summary>
        /// <param name="itemName">Item name</param>
        /// <returns>The <see cref="IItemData"/> instance in the cache having Id equal to <paramref name="itemName"/> if found or returns <see langword="null" /></returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="itemName"/> are <see langword="null" /> or empty.</exception>
        new T FindByName(string itemName);

        /// <summary>
        /// Finds the <see cref="IItemData"/> instance in the cache.
        /// </summary>
        /// <param name="itemAlias">Item aliasName</param>
        /// <returns>The <see cref="IItemData"/> instance in the cache having Id equal to <paramref name="itemAlias"/> if found or returns <see langword="null" /></returns>
        /// <exception cref="ArgumentNullException">If the passed <paramref name="itemAlias"/> are <see langword="null" /> or empty.</exception>
        new T FindByAlias(string itemAlias);


    }
}
